package cn.swu.lyx.homework2

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Button
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView

class managementSystem : AppCompatActivity() {



    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_management_system)


        val btn_user=findViewById<Button>(R.id.btn_user)
        val btn_order=findViewById<Button>(R.id.btn_order)
        val btn_commodity=findViewById<Button>(R.id.btn_commodity)
        val btn_annoucement=findViewById<Button>(R.id.btn_announcement)

        btn_user.setOnClickListener{
            replaceFragment(userFragment())
            //val intent= Intent(this,UserActivity::class.java)
            //startActivity(intent)
        }
        btn_order.setOnClickListener{
            replaceFragment(orderFragment())
        }
        btn_commodity.setOnClickListener{
            replaceFragment(commodityFragment())
        }
        btn_annoucement.setOnClickListener{
            replaceFragment(announcementFragment())
        }
        replaceFragment(userFragment())
    }

    private fun replaceFragment(fragment: Fragment){
        val fragmentManager=supportFragmentManager
        val transaction=fragmentManager.beginTransaction()
        transaction.replace(R.id.content,fragment)
        transaction.commit()
    }

}